package ntd.util.modular.ai.mapper;

import cn.hutool.core.lang.UUID;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import ntd.util.frame.data.factory.FactoryData;
import ntd.util.modular.ai.entity.Ai;
import org.springframework.stereotype.Component;

import java.sql.SQLException;
import java.util.List;

/**
 * Author: yyd
 * Date: 2023-10-24 14:27
 */
@Component
public class AiMapper {
    private static final Db db;

    static {
        db = Db.use(FactoryData.dataSource("272ab1b9c5cc4ea2b76302238247284c"));
    }

    public List<Entity> findAll() throws SQLException {
        return db.findAll(Entity.create("ai_server"));
    }

    public Object add(Entity entity) throws SQLException {
        return db.insert(entity);
    }



    public Object deleteById(String id) throws SQLException {
        return db.del(Entity.create("ai_server").set("id", id));
    }

    public List<Entity> selectById(String id) throws SQLException {
        return db.find(Entity.create("ai_server").set("id", id));
    }

    public Object update(Entity record, Entity where) throws SQLException {
        return  db.update(record, where);
    }
}
